<?php
include dirname(dirname(__FILE__)).'/s_user-manage/s_user-verify.php';
include dirname(dirname(dirname(__FILE__))).'/admin/productions-manage/functions.php';
include dirname(__FILE__)."/functions.php";
$user_rule = getProductionsRule();
?>
<html>
	<head>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php'; ?>
		<link rel="stylesheet" type="text/css" href="../../admin/css/style.css">
	
		<script src="../../js/jquery.ui.widget.js"></script>
		<script src="../../js/jquery.iframe-transport.js"></script>
		<script src="../../js/jquery.fileupload.js"></script>
		<script type="text/javascript">
	$(document).ready(function(){

			$("#accessory").fileupload({
			    url:"ajax/accessory-upload.php",//文件上传地址，当然也可以直接写在input的data-url属性内
			    formData:{},//如果需要额外添加参数可以在这里添加
			    done:function(e,result){
			        //done方法就是上传完毕的回调函数，其他回调函数可以自行查看api
			        //注意result要和jquery的ajax的data参数区分，这个对象包含了整个请求信息
			        //返回的数据在result.result中，假设我们服务器返回了一个json对象
			    	var json=JSON.parse(result.result);
			    	 if(typeof(json.error) != 'undefined'){
		                    if(json.error != ''){
		                        alert(json.error);
		                    }else{
			                    alert("上传成功");
		                    	$("#storeName").attr("value",json.storeName);
		                    	 $("#upload-div").hide();

		                    }
		                }
			    }
	
			});	



				$("#submit-btn").click(function(){
				var flag=true;
				var storeName=$.trim($("#storeName").val());
				if(storeName==""||storeName==null){
					alert("请提交材料");
					flag=false;
				}
				if(flag){
					$("#place-apply-form").submit();
				}
				
				
			});

		});
	</script>
	</head>
	<body>
		<div class="container">
		<div class="row">
		<div class="col-md-12">
			<div>
				<h3>申请流程</h3>
			</div>
			<div>
				<span>更新时间:<b><?php echo $user_rule['update_time']; ?></b></span>
				<div class="main-content">
					<p>
					    <?php 
					    	echo $user_rule['content'];
					    ?>
					</p>
				</div>
			</div>
		</div>
		</div>
		<div class="row" style="margin-top:50px;"></div>


		<?php
		$ret=getProductionsApplyBySUserId($_SESSION["s_user_id"]);
		if ($ret==null) {
			echo '<div class="form-horizontal col-md-offset-3" id="upload-div">
				
			<div class="form-group" >
				    <label for="accessory" class="col-sm-2 control-label">材料上传</label>
				    <div class="col-sm-5">
				      <input  type="file" name="accessory" class="form-control normal-input" id="accessory">
				    </div>
			</div>	
				
				 
			</div>
			
			 <form class="form-horizontal col-md-offset-3" id="place-apply-form" role="form" method="post" action="apply.php">
			 
			 
			  <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
			      <input class="btn btn-primary" id="submit-btn" type="button" value="确认申请">
			    </div>
			  </div>
			  <input name="submited" type="hidden" value="1">
			  <input name="storeName" id="storeName" type="hidden" value=""/>
			</form>';
	
		}else{
			echo ' <input class="btn btn-primary"  type="button" value="已经申请">';

		}
		?>
			
		</div>
	</body>
</html>